home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / Basic / Visual Basic.60 / COMMON / TOOLS / VCM / VCM.MDB / VcmComponentContainer / 10_Cabinet / frmpub.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-05-18  |  8.3 KB  |  259 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "ComDlg32.OCX"
  3. Begin VB.Form frmPublishers 
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "Publishers"
  6.    ClientHeight    =   3090
  7.    ClientLeft      =   3600
  8.    ClientTop       =   4530
  9.    ClientWidth     =   7350
  10.    Icon            =   "frmpub.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    LockControls    =   -1  'True
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   3090
  16.    ScaleWidth      =   7350
  17.    ShowInTaskbar   =   0   'False
  18.    Begin VB.CommandButton cmdAbout 
  19.       Caption         =   "&About"
  20.       Height          =   375
  21.       Left            =   5880
  22.       TabIndex        =   9
  23.       Top             =   630
  24.       Width           =   945
  25.    End
  26.    Begin VB.CommandButton cmdDone 
  27.       Cancel          =   -1  'True
  28.       Caption         =   "&Done"
  29.       Height          =   375
  30.       Left            =   5880
  31.       TabIndex        =   8
  32.       Top             =   240
  33.       Width           =   945
  34.    End
  35.    Begin VB.OptionButton optListBox 
  36.       Caption         =   "Use Standard List Box"
  37.       Height          =   255
  38.       Left            =   3360
  39.       TabIndex        =   7
  40.       Top             =   1860
  41.       Width           =   2295
  42.    End
  43.    Begin VB.OptionButton optComboBox 
  44.       Caption         =   "Use Standard Combo Box"
  45.       Height          =   255
  46.       Left            =   3360
  47.       TabIndex        =   6
  48.       Top             =   1560
  49.       Value           =   -1  'True
  50.       Width           =   2295
  51.    End
  52.    Begin VB.TextBox txtCity 
  53.       DataSource      =   "datPublishers"
  54.       Height          =   285
  55.       Left            =   1740
  56.       Locked          =   -1  'True
  57.       TabIndex        =   3
  58.       Top             =   1140
  59.       Width           =   4000
  60.    End
  61.    Begin VB.TextBox txtAddress 
  62.       DataSource      =   "datPublishers"
  63.       Height          =   285
  64.       Left            =   1740
  65.       Locked          =   -1  'True
  66.       TabIndex        =   2
  67.       Top             =   840
  68.       Width           =   4000
  69.    End
  70.    Begin VB.TextBox txtCompanyName 
  71.       DataSource      =   "datPublishers"
  72.       Height          =   285
  73.       Left            =   1740
  74.       Locked          =   -1  'True
  75.       TabIndex        =   1
  76.       Top             =   540
  77.       Width           =   4000
  78.    End
  79.    Begin VB.TextBox txtName 
  80.       DataSource      =   "datPublishers"
  81.       Height          =   285
  82.       Left            =   1740
  83.       Locked          =   -1  'True
  84.       TabIndex        =   0
  85.       Top             =   240
  86.       Width           =   4000
  87.    End
  88.    Begin VB.Data datPublishers 
  89.       Align           =   2  'Align Bottom
  90.       Connect         =   "Access"
  91.       DatabaseName    =   ""
  92.       DefaultCursorType=   0  'DefaultCursor
  93.       DefaultType     =   2  'UseODBC
  94.       Exclusive       =   0   'False
  95.       Height          =   345
  96.       Left            =   0
  97.       Options         =   0
  98.       ReadOnly        =   0   'False
  99.       RecordsetType   =   2  'Snapshot
  100.       RecordSource    =   ""
  101.       Top             =   2745
  102.       Width           =   7344
  103.    End
  104.    Begin VB.ComboBox cboState 
  105.       DataSource      =   "datPublishers"
  106.       Height          =   315
  107.       Left            =   1740
  108.       Sorted          =   -1  'True
  109.       TabIndex        =   4
  110.       Text            =   "cmbState"
  111.       Top             =   1455
  112.       Width           =   1215
  113.    End
  114.    Begin VB.ListBox lstState 
  115.       DataSource      =   "datPublishers"
  116.       Height          =   675
  117.       Left            =   1740
  118.       Sorted          =   -1  'True
  119.       TabIndex        =   5
  120.       Top             =   1455
  121.       Visible         =   0   'False
  122.       Width           =   1215
  123.    End
  124.    Begin MSComDlg.CommonDialog dlgDialog 
  125.       Left            =   120
  126.       Top             =   2160
  127.       _ExtentX        =   847
  128.       _ExtentY        =   847
  129.       FontSize        =   1.73857e-39
  130.    End
  131.    Begin VB.Label Label5 
  132.       Alignment       =   1  'Right Justify
  133.       Caption         =   "State:"
  134.       Height          =   195
  135.       Left            =   360
  136.       TabIndex        =   14
  137.       Top             =   1500
  138.       Width           =   1305
  139.    End
  140.    Begin VB.Label Label4 
  141.       Alignment       =   1  'Right Justify
  142.       Caption         =   "City:"
  143.       Height          =   195
  144.       Left            =   360
  145.       TabIndex        =   13
  146.       Top             =   1200
  147.       Width           =   1305
  148.    End
  149.    Begin VB.Label Label3 
  150.       Alignment       =   1  'Right Justify
  151.       Caption         =   "Address:"
  152.       Height          =   195
  153.       Left            =   360
  154.       TabIndex        =   12
  155.       Top             =   900
  156.       Width           =   1305
  157.    End
  158.    Begin VB.Label Label2 
  159.       Alignment       =   1  'Right Justify
  160.       Caption         =   "Company Name:"
  161.       Height          =   195
  162.       Left            =   360
  163.       TabIndex        =   11
  164.       Top             =   600
  165.       Width           =   1305
  166.    End
  167.    Begin VB.Label Label1 
  168.       Alignment       =   1  'Right Justify
  169.       Caption         =   "Name:"
  170.       Height          =   195
  171.       Left            =   360
  172.       TabIndex        =   10
  173.       Top             =   300
  174.       Width           =   1305
  175.    End
  176. Attribute VB_Name = "frmPublishers"
  177. Attribute VB_GlobalNameSpace = False
  178. Attribute VB_Creatable = False
  179. Attribute VB_PredeclaredId = True
  180. Attribute VB_Exposed = False
  181. Option Explicit
  182. Private Sub cmdAbout_Click()
  183.    Dim frmX As New frmAbout
  184.    ' Display the About dialog box
  185.    frmX.Show vbModal
  186.    Set frmX = Nothing
  187. End Sub
  188. Private Sub cmdDone_Click()
  189.    Unload Me
  190. End Sub
  191. Private Sub Form_Load()
  192.    Dim vntTemp As Variant
  193.    Dim vnDummy As Variant
  194.    On Error GoTo Form_LoadError
  195.    ' Retrieve all the states in the table
  196.    datPublishers.DatabaseName = "biblio.mdb"
  197.    datPublishers.RecordSource = "SELECT DISTINCT state FROM Publishers"
  198.    datPublishers.Refresh
  199.    ' Load the distinct state abbreviations into the List and Combo Controls
  200.    ' If the database name file is not valid an trappable error will occur here
  201.    Do While Not datPublishers.Recordset.EOF
  202.       vntTemp = datPublishers.Recordset!State
  203.       If IsNull(vntTemp) Then vntTemp = ""
  204.       cboState.AddItem CStr(vntTemp)
  205.       lstState.AddItem CStr(vntTemp)
  206.       datPublishers.Recordset.MoveNext
  207.    Loop
  208.    ' Retrieve all records from Publishers table
  209.    datPublishers.RecordSource = "Publishers"
  210.    datPublishers.RecordsetType = vbRSTypeTable
  211.    datPublishers.Refresh
  212.    ' Link fields with data control
  213.    txtName.DataField = "Name"
  214.    txtAddress.DataField = "Address"
  215.    txtCompanyName.DataField = "Company Name"
  216.    txtCity.DataField = "City"
  217.    cboState.DataField = "State"
  218.    lstState.DataField = "State"
  219. Form_LoadExit:
  220. Exit Sub
  221. Form_LoadError:
  222.     ' If the Biblio database can't be found, open the common dialog control
  223.     ' to let the user find it.  The biblio.mdb file is located in the same
  224.     ' directory in which vb5 has been installed.
  225.     If Err = 3024 Then
  226.         With dlgDialog
  227.             .DialogTitle = "Can't Find Biblio.mdb"
  228.             .Filter = "(*.MDB)|*.mdb"
  229.             .ShowOpen
  230.         End With
  231.         
  232.         If dlgDialog.filename <> "" Then
  233.         'make sure that the database file returned is indeed biblio.mdb
  234.             If Right(UCase(dlgDialog.filename), Len("\biblio.mdb")) = "\BIBLIO.MDB" Then
  235.                 datPublishers.DatabaseName = dlgDialog.filename
  236.                 datPublishers.RecordSource = "SELECT DISTINCT state FROM Publishers"
  237.                 datPublishers.Refresh
  238.             End If
  239.             Resume Next
  240.         Else
  241.             Unload Me
  242.         End If
  243.     ElseIf Err <> 0 Then ' another error
  244.         MsgBox "Unexpected Error: " & Err.Description
  245.         End
  246.     End If
  247.     Resume Form_LoadExit
  248. End Sub
  249. Private Sub optComboBox_Click()
  250.    ' toggle the visibility of the controls
  251.    cboState.Visible = True
  252.    lstState.Visible = False
  253. End Sub
  254. Private Sub optListBox_Click()
  255.    ' toggle the visibility of the controls
  256.    cboState.Visible = False
  257.    lstState.Visible = True
  258. End Sub
  259.